#include "Intent.h"

Intent::Intent()
{

}

Intent::~Intent()
{

}

void Intent::putExtra(string key, string value)
{
    m_extra_s[key] = value;
}

void Intent::putExtra(string key, int value)
{
    m_extra_i[key] = value;
}

void Intent::putExtra(string key, double value)
{
    m_extra_d[key] = value;
}

void Intent::putExtra(string key, bool value)
{
    m_extra_b[key] = value;
}

bool Intent::getExtraString(string key, string& value)
{
    auto m_it = m_extra_s.find(key);
    if (m_it != m_extra_s.end()) {
        value = m_it->second;
        return true;
    }
    return false;
}

string Intent::getExtraStringDefault(string key, string defaultValue)
{
    auto m_it = m_extra_s.find(key);
    if (m_it != m_extra_s.end()) {
        return m_it->second;
    }
    return defaultValue;
}

bool Intent::getExtraInt(string key, int& value)
{
    auto m_it = m_extra_i.find(key);
    if (m_it != m_extra_i.end()) {
        value = m_it->second;
        return true;
    }
    return false;
}

int Intent::getExtraIntDefault(string key, int defaultValue)
{
    auto m_it = m_extra_i.find(key);
    if (m_it != m_extra_i.end()) {
        return m_it->second;
    }
    return defaultValue;
}

bool Intent::getExtraDouble(string key, double& value)
{
    auto m_it = m_extra_d.find(key);
    if (m_it != m_extra_d.end()) {
        value = m_it->second;
        return true;
    }
    return false;
}

double Intent::getExtraDoubleDefault(string key, double defaultValue)
{
    auto m_it = m_extra_d.find(key);
    if (m_it != m_extra_d.end()) {
        return m_it->second;
    }
    return defaultValue;
}

bool Intent::getExtraBool(string key, bool& value)
{
    auto m_it = m_extra_b.find(key);
    if (m_it != m_extra_b.end()) {
        value = m_it->second;
        return true;
    }
    return false;
}

bool Intent::getExtraBoolDefault(string key, bool defaultValue)
{
    auto m_it = m_extra_b.find(key);
    if (m_it != m_extra_b.end()) {
        return m_it->second;
    }
    return defaultValue;
}
